function trim(val)
{
	 return val.replace(/(^\s*)|(\s*$)/g, "");
}

function isMaxLen(o)
{
	 var nMaxLen=o.getAttribute? parseInt(o.getAttribute("maxlength")):"";
	 if(o.getAttribute && o.value.length>nMaxLen)
	 {
	 	  o.value=o.value.substring(0,nMaxLen);
	 }
}



function selectAll(){
	var checkall = document.getElementById('checkall');
	var listsize = document.getElementById('listsize').value;
	for(var i=0;i<listsize;i++){
		if(checkall.checked){
			document.getElementById('checkone'+i).checked = true;
		}else{
			document.getElementById('checkone'+i).checked = false;
		}
	}
}

function judgeCheck()
{
    var pkid_string = '';
		var listsize = document.getElementById('listsize').value;
		for(var i=0;i<listsize;i++)
		{
				if(document.getElementById('checkone'+i).checked)
				{
					pkid_string += document.getElementById('checkone'+i).value+'|';
				}
		}
    return pkid_string;
}

//var one_member_price ='';





function changeTime(){

	var obj = document.getElementById('up_operating').value;
	if( obj == '' || obj.indexOf('-')>-1 || obj.indexOf('c')>-1 || obj.indexOf('d')>-1 ){
		document.getElementById('b_g').style.display = 'none';
	}else{
		document.getElementById('b_g').style.display = 'inline';
	}
}

function operateInfo(val){

	var oper = document.getElementById(val+'_operating').value;
	if(oper == ''){
		alert('请选择操作方式!');
		return false;
	}

	var listsize = document.getElementById('listsize').value;

	var pkid_string = judgeCheck();
	if( pkid_string == '' ){
		alert('请至少选择一条信息进行操作!');
		return false;
	}
	if( oper == '-' ){
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action = '/doTradeReg.do';
		document.getElementById('bpm_id').value = '9701';
		if(window.confirm('确认删除吗?')){
			document.indexForm.submit();
		}
 	} else if( 'abcd'.indexOf(oper) > -1 ) {
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action='/doTradeReg.do';
		document.getElementById('bpm_id').value = '8336';
		if(window.confirm('确认提交吗?')){
			document.indexForm.submit();
		}
	} else {
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action='/doTradeReg.do';
		document.getElementById('bpm_id').value = '2491';
		if(window.confirm('确认提交吗?')){
			document.indexForm.submit();
		}
	}

}

function deleteOneInfo(pkid,bpm_id)
{

	if(window.confirm('确认删除吗？'))
	{
	  window.location.href='/doTradeReg.do?pkid='+pkid+'&bpm_id='+bpm_id;
 	}
}




function subForm(){

	if(trim(document.getElementById('title').value)==''){
	  alert('请输入信息标题！');
	  document.getElementById('title').focus();
	  return;
	}

	if(trim(document.getElementById('company').value)==''){
	  alert('请输入公司名称！');
	  document.getElementById('company').focus();
	  return;
	}

	if(document.getElementById('class_attr').value == ''){
		var class_id_group = '';
		for( var i=1;i<4;i++ ){
			if( document.getElementById('sort'+i).value !=''){
				class_id_group += document.getElementById('sort'+i).value + '|';
			}
		}
		if(class_id_group == ''){
			alert('请选择所属分类！');
			return;
		}
		document.getElementById('class_attr').value = class_id_group;
	}

	if(document.getElementById('province').value!=''){
		var area_attr_str = '';
		area_attr_str += document.getElementById('province').value+'|';
		if(document.getElementById('eparchy_code').value!=''){
			area_attr_str += document.getElementById('eparchy_code').value+'|';
			if(document.getElementById('city_code').value!=''){
				area_attr_str += document.getElementById('city_code').value+'|';
			}
		}
		if(area_attr_str == ''){
			alert('请选择工作地区！');
			return;
		}
		document.getElementById('area_attr').value = area_attr_str;
	}

	if(trim(document.getElementById('career').value)==''){
	  alert('请输入工作岗位！');
	  document.getElementById('career').focus();
	  return;
	}
	if(trim(document.getElementById('email').value)==''){
	  alert('请输入E-mail！');
	  document.getElementById('email').focus();
	  return;
	}

	var str = CKEDITOR.instances.job_desc.getData();
	str = trim(str);
	if(str == ''){
		alert('请输入详细说明!');
		CKEDITOR.instances.job_desc.focus();
		return;
	}

	var n = 0;

	var smObj = document.getElementsByName('end_date');
	for (var i = 0; i < smObj.length; i++){
		if(smObj[i].checked) {
			n++;
		}
	}

	if(n == 0){
		alert('请选择信息有效期！');
		return;
	}

	document.addForm.submit();

}

function ChangeClassStyle(){
	document.getElementById("class_attr").value = '';
	document.getElementById("classId1").style.display = 'none';
	document.getElementById("classId2").style.display = 'block';
}

function ChangeAreaStyle(){
	document.getElementById("area_attr").value = '';
	document.getElementById("areaId1").style.display = 'none';
	document.getElementById("areaId2").style.display = 'block';
}

function searchForm(){

	document.indexForm.submit();

}

var type = '6';

var fectureArray=new Array();
fectureArray=['请选择'];


function setSecondClass(val) {
	if(document.getElementById('sort1').value == ''){
		document.getElementById('sort2').style.display = 'none';
		document.getElementById('sort3').style.display = 'none';
		document.getElementById('sort1').value = '';
		document.getElementById('sort2').value = '';
		document.getElementById('sort3').value = '';
	}else{
		Ts_categoryInfo.getCatClassByUpId(val, type, setSort2);
	}
}

function setSort2(map_data) {

	var up_class_id = document.getElementById('sort1').value;
	if (map_data != null) {
		Ts_categoryInfo.checkCatSonById(up_class_id,function(ret){
		 if(ret == '1'){
		 }else{
		 	 	DWRUtil.removeAllOptions('sort2');
				DWRUtil.addOptions('sort2',fectureArray);
				DWRUtil.addOptions('sort2', map_data);
				var item = document.getElementById('sort2').length;
				if (item == 0) {
					document.getElementById('sort2').style.display = 'none';
				} else {
					document.getElementById('sort2').style.display = 'inline';
				}
		 }
	 });
	}
}

function setTherdClass(val) {

	Ts_categoryInfo.getCatClassByUpId(val, type, setSort3);
}

function setSort3(map_data) {

	var up_class_id = document.getElementById('sort2').value;

	if (map_data != null) {
		Ts_categoryInfo.checkCatSonById(up_class_id,function(ret){
		 if(ret == '1'){
		 }else{
		 	 	DWRUtil.removeAllOptions('sort3');
				DWRUtil.addOptions('sort3',fectureArray);
				DWRUtil.addOptions('sort3', map_data);
				var item = document.getElementById('sort3').length;
				if (item == 0) {
					document.getElementById('sort3').style.display = 'none';
				} else {
					document.getElementById('sort3').style.display = 'inline';
				}
		 }
	 });
	}
}



function setProvince()
{
	Ts_areaInfo.getAreaClassByUpId('000000000000000',function(data){
		DWRUtil.removeAllOptions('province');
		DWRUtil.addOptions('province',{'':'请选择'});
		DWRUtil.addOptions('province',data);
	})
}
function setCitys(prov)
{
   var provence=prov;
	 Ts_areaInfo.getAreaClassByUpId(provence,function(data){
		DWRUtil.removeAllOptions('eparchy_code');
		DWRUtil.addOptions('eparchy_code',{'':'请选择'});
		DWRUtil.addOptions('eparchy_code',data);
		DWRUtil.removeAllOptions('city_code');
		DWRUtil.addOptions('city_code',{'':'请选择'});
	});
}

function setAreas(city_id){
	Ts_areaInfo.getAreaClassByUpId(city_id,function(data){
	 	DWRUtil.removeAllOptions('city_code');
		DWRUtil.addOptions('city_code',{'':'请选择'});
	 	DWRUtil.addOptions('city_code',data);
	});
}